﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xunit;
using Rhino.Mocks;
using System.Web;
using Rarous.Gryphoon.Web.Controllers;
using System.Web.Mvc;
using HaackMvcHelpers;

namespace Rarous.Gryphoon.Spec.Web {
  public class ArticleControllerSpec {
    private MockRepository mockery;

    /// <summary>
    /// Konstruktor. Vytvoří novou instanci ArticleControllerSpec.
    /// </summary>
    public ArticleControllerSpec() {
      mockery = new MockRepository();
    }

    [Fact]
    public void ArticleController_DefaultActionShouldShowEditor() {
      TestArticleController controller = new TestArticleController();

      controller.Index();

      Assert.Equal("Editor", controller.ActualViewName);
    }
  }

  public class TestArticleController : ArticleController, ITestController {
    public string ActualViewName {
      get;
      set;
    }

    public string RedirectViewName {
      get;
      set;
    }

    public string ActualMasterName {
      get;
      set;
    }

    public object ActualViewData {
      get;
      set;
    }

    protected override void RenderView(string viewName, string masterName, object viewData) {
      ActualViewName = viewName;
      ActualMasterName = masterName;
      ActualViewData = viewData;
    }

    protected override void RedirectToAction(object values) {
      RedirectViewName = values.ToDictionary()["Action"];
    }

  }
}
